package com.itheima.hmshopping.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class R<T> implements Serializable {
    private Integer code;
    private T data;
    private String message;

    //执行成功
    public static <T>R<T> succeed(T data,String message){
        R<T> r=new R<T>();
        r.code=200;
        r.data=data;
        r.message=message;
        return r;
    }
    //执行失败
    public static <T> R<T> error(String message){
        R<T> r=new R<T>();
        r.code=500;
        r.message=message;
        return r;
    }
}
